from marshmallow import Schema
from flask_restplus import Namespace, fields


def hello_mds(ns):
    hello_md = ns.model(
        "Hello",
        {
            "rate": fields.Integer(description="数字"),
            "name": fields.String(required=True, enum=["yanziliang", "ziliang"]),
            "age": fields.Integer(max=23),
        },
    )
    return hello_md


def post_hello_mds(ns, hello_md):
    hello_md_post = ns.model(
        "Hello_post", {"total": fields.Integer(), "data": fields.List(fields.Nested(hello_md))}
    )
    return hello_md_post


class TestSchemas(object):
    def __init__(self, namespace):
        self.ns = namespace

    def file_update_query(self):

        return self.ns.model(
            "file_query",
            {
                "file": fields.String(description="文件列表"),
            },
        )

    def file_update_body(self):
        return self.ns.model("file_body", {"url": fields.String()})
